import set from '@dfeidao/atom-web/local/set';
import get from '@dfeidao/atom-web/storage/get';

import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import { IFeidaoAiBrowserComponent } from '@dfeidao/web/interfaces';
// import show from '../../atom/show';
import hide_loading from '../../atom/hide-loading';
import show_loading from '../../atom/show-loading';
import P01 from './P01';
import P04 from './P04';
import P05 from './P05';


export default async function a000(fd: IFeidaoAiBrowserComponent, args: { role_no: string; role_type_id: string, id: string }) {
	//  调用事件
	fd.data.node.querySelector<HTMLDivElement>('[id="zj11"]').classList.remove('display-n');
	const role_no = args.role_no;
	// const id = args.id;
	const productid = get('productid');
	// console.log(productid);

	const role_type_id = args.role_type_id;

	const page_no = 1;
	const page_size = 10;
	set(fd, 'page_no', page_no);
	set(fd, 'page_size', page_size);
	set(fd, 'productid', productid);
	set(fd, 'role_type_id', role_type_id);
	set(fd, 'role', {
		role_no, role_type_id
	});
	show_loading();
	const res = await nodejs<{ dataArray: object[], count: number, page_no: number, page_size: number }>('roler/service/pub_role_allot_find', { productid, role_no, page_no, page_size });
	hide_loading();
	res.page_no = page_no;
	res.page_size = page_size;

	if (res.count === 0) {

		fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="P05"]').innerHTML = '';
		render(fd, '', P01, 'P01', 'inner');
		render(fd, '', P04, 'P04', 'inner');
	} else {


		render(fd, res.dataArray, P01, 'P01', 'inner');
		fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="P04"]').innerHTML = '';
		res.page_no = page_no;
		res.page_size = page_size;
		render(fd, res, P05, 'P05', 'inner');
	}
}
